package com.lin.chapter8;

import java.lang.reflect.Constructor;

public class SingleFactory {
	private static Singleton singleton;

	static {
		try{
			Class<?> clazz = Class.forName(Singleton.class.getName());
			Constructor<?> constructor = clazz.getDeclaredConstructor();
			constructor.setAccessible(true);
			singleton = (Singleton) constructor.newInstance();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static Singleton getSingleton(){
		return singleton;
	}
}
